package com.school.basic.controller;

import com.school.basic.entity.TeacherInfo;
import com.school.basic.service.TeacherInfoService;
import com.school.untils.ResultEntity;
import com.school.untils.ResultUtils;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;


@Api(tags = "教师信息管理")
@RestController
@RequestMapping("/teacherInfo")
public class TeacherInfoController {
    @Autowired
    TeacherInfoService teacherInfoService;
    // 根据教师账号密码查询教师信息
    @ApiOperation("根据教师账号密码查询教师信息")
    @RequestMapping(value = "/findTeacherByAccountAndPassword",method = RequestMethod.GET)
    public ResultEntity findTeacherByAccountAndPassword(Integer account, String password){
        return ResultUtils.build(teacherInfoService.findTeacherByAccountAndPassword(account, password));
    }

    // 新增
    @ApiOperation("教师信息增加")
    @RequestMapping(value = "/add",method = RequestMethod.POST)
    public ResultEntity addTeacherInfo(@RequestBody TeacherInfo teacherInfo){
        return ResultUtils.build(teacherInfoService.addTeacherInfo(teacherInfo));
    }

    // 查询所有
    @ApiOperation("教师信息查询所有")
    @RequestMapping(value = "/findAll",method = RequestMethod.GET)
    public ResultEntity<Object> findAll(){
        return ResultUtils.build(teacherInfoService.findAll());
    }

    // 更新
    @ApiOperation("教师信息更新")
    @RequestMapping(value = "/update",method = RequestMethod.POST)
    public ResultEntity updateTeacherInfo(@RequestBody TeacherInfo teacherInfo){
        return ResultUtils.build(teacherInfoService.updateTeacherInfo(teacherInfo));
    }

    // 老师状态变更
    @ApiOperation("教师状态变更")
    @RequestMapping(value = "/updateStatus",method = RequestMethod.POST)
    public void updateStatus(String id,Integer status){
        teacherInfoService.updateStatus(id,status);
    }

    // 根据id查看详情
    @ApiOperation("教师信息查看详情")
    @GetMapping("/getDetailsById/{id}")
    public ResultEntity getDetailsById(@PathVariable("id") String id){
        return ResultUtils.build(teacherInfoService.getDetailsById(id));
    }

    // 根据id删除
    @ApiOperation("教师信息信息删除")
    @DeleteMapping("/delete/{id}")
    public void deleteTeacherInfo(@PathVariable("id") String id){
        teacherInfoService.deleteTeacherInfo(id);
    }

    // 根据id批量删除
    @ApiOperation("教师信息批量删除")
    @DeleteMapping("/batch")
    public void deleteTeacherInfoList(String idList){
        teacherInfoService.deleteTeacherInfoList(idList);
    }

    // 根据条件分页查询
    @ApiOperation("根据条件分页查询")
    @GetMapping("/specificPage")
    public ResultEntity specificPageQueryTeacherInfoList(TeacherInfo teacherInfo, @RequestParam int page, @RequestParam int size){
        return ResultUtils.build(teacherInfoService.specificPageQueryTeacherInfoList(teacherInfo,page,size));
    }

    // 根据学校ID查询所有
    @ApiOperation("根据学校ID查询所有")
    @GetMapping("/findAllBySchoolId")
    public ResultEntity<Object> findAllBySchoolId(Integer schoolId){
        return ResultUtils.build(teacherInfoService.findAllBySchoolId(schoolId));
    }
}
